<extend name="Public:base" />
<block name="title">个人信息修改</block>
<block name="content">
    <webuploadercss />
    <webuploaderjs />
    <form action="" method="post" id="ajaxForm">
    <div class="page__bd">
        <div class="weui-panel__bd ">
            <div class="weui-cell beizhu_kuang">
                <div class="weui-cell__hd"><label class="weui-label xinxi_label">图片</label></div>
                <div class="weui-cell__bd ">
                    <ul class="xinxi_ul_list">
                        <webuploader name="pic" url="{:U('Home/User/ajax_upload')}" word="或将照片拖到这里，单次最多可选300张" />
                        <li><img src="__ROOT__{$hos['pic']}" id="titlepicpreview"/></li>
                        <!--<li><a href="" class="jia_ann" >+</a></li>-->
                        <!--<input type="hidden"  id="titlepic" name='pic' value="{$hos['pic']}"/>
                        <li>
                            <a href="javascript:;" class="jia_ann" id="uploadbtn">+</a>
                        </li>-->
                        <!--<li>&lt;!&ndash;<label>图片:</label>&ndash;&gt;<input type="text"  id="titlepic" name='pic' />
                            <input type="button" id="uploadbtn" value="选择图片" style="height:30px;width:80px;cursor:pointer;border-radius:2px;background-color:#DDD;" /><i>限jpg gif jpeg png 格式 200kb以内</i></li>-->
                        <!--<li><img src="{$hos['pic']}" id="titlepicpreview"/></li>-->
                    </ul>
                </div>
            </div>
            <div class="weui-cell beizhu_kuang">
                <div class="weui-cell__hd"><label class="weui-label xinxi_label">简介</label></div>
                <div class="weui-cell__bd ">
                    <textarea class="weui-textarea" name="content" placeholder="请输入文本" rows="3" id="content">{$hos['content']}</textarea>
                </div>
            </div>
            <div class="button-sp-area xinxi_but_area">
                <a href="__MODULE__/User/userlist" class="weui-btn weui-btn_mini weui-btn_default">返回</a>
                <a href="javascript:;" id="mod" class="weui-btn weui-btn_mini weui-btn_primary">修改</a>
            </div>
        </div>
    </div>
    </form>
    <script type="text/javascript">
        $(document).on('click','#mod',function(){
            var content = $('textarea[name=content]').val();
            if(content == ''){
                layer.msg('请填写简介！');
                return false;
            }
            var formData = $('#ajaxForm').serialize();
            $.ajax({
                type:'post',
                url:'__MODULE__/User/usermod',
                data:formData,
                cache:false,
                dataType:'json',
                success:function(res){
                    if(res.code == 0){
                        layer.msg(res.msg,{time:2000},function () {
                            window.location.href = res.url;
                        });
                        return false;
                    }else{
                        layer.msg(res.msg);
                        return false;
                    }
                }
            });
        });
    </script>
    <script type="text/javascript" charset="utf-8" src="__PUBLIC__/kindeditor/kindeditor-min.js"></script>
    <script type="text/javascript" charset="utf-8" src="__PUBLIC__/kindeditor/lang/zh_CN.js"></script>
    <script type="text/javascript">
        KindEditor.ready(function(K) {
            K.create('#pagecontent', {
                allowFileManager : true
            });

            var editor = K.editor({
                allowFileManager : true
            });
            //上传图片（本地、网络）
            K('#uploadbtn').click(function() {
                editor.loadPlugin('image', function() {
                    editor.plugin.imageDialog({
                        showRemote : false,
                        imageUrl : K('#titlepic').val(),
                        clickFn : function(url, title, width, height, border, align) {
                            K('#titlepic').val(url);
                            K('#titlepicpreview').attr('src', url);
                            editor.hideDialog();
                        }
                    });
                });
            });

            //文件上传
            K('#insertfile').click(function() {
                editor.loadPlugin('insertfile', function() {
                    editor.plugin.fileDialog({
                        fileUrl : K('#fileurl').val(),
                        clickFn : function(url, title) {
                            K('#fileurl').val(url);
                            editor.hideDialog();
                        }
                    });
                });
            });
        });
    </script>
</block>